//
//  HYPresentationController.swift
//  HYYWeibo
//
//  Created by HY-Mac on 16/7/10.
//  Copyright © 2016年 HY-Mac. All rights reserved.
//

import UIKit



class HYPresentationController: UIPresentationController {
    var presentViewFrame = CGRectZero
    override init(presentedViewController: UIViewController, presentingViewController: UIViewController) {
        super.init(presentedViewController: presentedViewController, presentingViewController: presentingViewController)
    }
    
    
    override func containerViewWillLayoutSubviews() {
        presentedView()?.frame = presentViewFrame
        containerView?.insertSubview(coverBtn, atIndex: 0)
        coverBtn.addTarget(self, action: #selector(HYPresentationController.coverBtnDidClick), forControlEvents: .TouchUpInside)
    }
    private lazy var coverBtn: UIButton = {
        ()  -> UIButton
        in
        let btn = UIButton(frame: UIScreen.mainScreen().bounds)
        //btn.backgroundColor = UIColor.greenColor()
        return btn
        
    }()
    @objc private func coverBtnDidClick(){
        presentedViewController.dismissViewControllerAnimated(true) { 
            
        }
    }

}
